package com.springboot.love.service.impl;

import com.springboot.love.dao.AdminDao;
import com.springboot.love.entity.AdminUser;
import com.springboot.love.service.AdminUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * (Admin)表服务实现类
 */
@Service("adminService")
@Slf4j
public class AdminUserServiceImpl implements AdminUserService {

    @Resource
    private AdminDao adminDao;

    /**
     * 通过账号查询用户
     *
     * @param username 账号
     * @return 实例对象
     */
    @Override
    public AdminUser queryByUsername(String username) {
        return this.adminDao.queryByUsername(username);
    }

    /**
     * 记录用户登录
     * @param adminUser
     */
    @Override
    public void logadminLogin(AdminUser adminUser) {
        AdminUser temp=new AdminUser();
        temp.setAdminId(adminUser.getAdminId());
        temp.setAdminlastLoginTime(new Date());
        adminDao.updateById(temp);
    }
}
